package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.Pojo.entity.Comment;
import cn.tedu._04mybatis.Pojo.vo.SelectCommentVO1;
import cn.tedu._04mybatis.Pojo.vo.SelectCommentVO2;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {

    @Insert("INSERT INTO comment(content,created,user_id,weibo_id) values (#{content},#{created},#{userId},#{weiboId})")
    void insertCommeent(Comment comment);

    @Delete("DELETE  FROM comment WHERE id = #{id}")
    int  deleteById(Long id);

    @Update("UPDATE comment  SET content=#{content}  WHERE id=#{id} ")
    int updateComment(Comment comment);

    @Select("SELECT content ,user_id userId, weibo_id  weiboId FROM comment WHERE id = #{id}")
    SelectCommentVO1 selectCommentById1(Long id);

    @Select("SELECT content, user_id userId FROM comment WHERE weibo_id = #{weiboId}")
    List<SelectCommentVO2> selectCommentById2(Long weiboId);



}
